package com.studies.pc.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.studies.common.R.R;
import com.studies.pc.pojo.Activity;
import com.studies.pc.service.ActivityService;
import com.studies.pc.vo.ActivityDetailsVo;
import com.studies.pc.query.ActivityQuery;
import com.studies.pc.vo.ActivityschyearVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 研学活动 前端控制器
 * </p>
 *
 * @author 研学活动后台
 * @since 2019-12-24
 */
@Api(tags="活动模块")
@CrossOrigin //跨域
@RestController
@RequestMapping("/pc/activity")
public class ActivityController {


    @Autowired
    private ActivityService activityServi;


    @ApiOperation(value = "分页活动列表")
    @GetMapping(value = "selectPage{nowPage}{pageSize}")
    public R selectPage(
                          @ApiParam(name = "activityVo", value = "条件", required = false)
                                  ActivityQuery activityVo,
                         @ApiParam(name = "nowPage", value = "当前页码", required = false)
                             Long nowPage,
                          @ApiParam(name = "pageSize", value = "每页记录数", required = true)
                          @PathVariable Long pageSize
    ){
        if (nowPage==null){
            nowPage= Long.valueOf(1);
        }
        Page<Activity> pageParam = new Page<Activity>(nowPage, pageSize);

        Map<String, Object> map = activityServi.selectPage(pageParam,activityVo);

        return  R.ok().data(map);
    }

    @ApiOperation(value = "活动信息")
    @PostMapping(value = "activityDetails")
//    /{studiesid}
    public R activityDetails(  @ApiParam(name = "studiesid", value = "活动id", required = true)
                                           Integer studiesid
                       ){
        ActivityDetailsVo activityDetailsVo = activityServi.activityDetails(studiesid);

        return  R.ok().data("itms",activityDetailsVo);
    }

    @ApiOperation(value = "活动学年")
    @PostMapping(value = " getAllSchYear")
    public R getAllSchYear(
    ){
        ActivityschyearVo allSchYear = activityServi.getAllSchYear();

        return  R.ok().data("itms",allSchYear);
    }
    @ApiOperation(value = "得到统计总数")
    @PostMapping(value = "getActivityStatisticsCount/{schyear}")
    public R getActivityStatisticsCount(@ApiParam(name = "schyear", value = "学年", required = false)
                                            @PathVariable String schyear){
        return null;
    }
    @ApiOperation(value = "得到统计筛选项")
    @PostMapping(value = "getSelectItem/{schyear}")
    public R getSelectItem(){
        return null;
    }
}

